import java.util.concurrent.locks.ReentrantLock;

public class Demo2 {
    public static void main(String[] args) {
        ReentrantLock reentrantLock=new ReentrantLock(true); //为true是公平锁false就为非公平锁，不加默认为公平锁。
        try {
            reentrantLock.tryLock();

        }finally {
            if (reentrantLock.tryLock()) {
                reentrantLock.unlock();
            }
        }

    }
}
